#include <stdio.h>
long long A=1992919, B=18181971;
FILE *f;
char s[20];
int ts=1;
int next()
{
	A=(A*13166771+B)%1000000007;
	B=(B*67771+A)%1000000007;
	return A;
}
void createtest() { sprintf(s, "%03d", ts); ts++; f=fopen(s, "w"); }
void gen0()
{
	createtest();
	fprintf(f, "5 3\n1 5 7 10 14\n");
	createtest();
	fprintf(f, "1 1\n400000\n");
	createtest();
	fprintf(f, "2 1\n0 400000\n");
	createtest();
	fprintf(f, "2 2\n0 1\n");
	createtest();
	fprintf(f, "3 1\n0 1 10\n");
	createtest();
	fprintf(f, "4 2\n0 4 5 9\n");
	createtest();
	fprintf(f, "10 2\n0 1 2 3 4 5 6 7 8 10\n");
}
void gen1(int n, int k)
{
	createtest();
	int i;
	for(fprintf(f, "%d %d\n", n, k), i=0; i<n; fprintf(f, "%d%c", next()%400000, i<n-1?' ':'\n'), i++);
}
void gen2(int n, int k, int t)
{
	createtest();
	int i;
	for(fprintf(f, "%d %d\n", n*t, k*t); t--; )
		for(i=0; i<n; fprintf(f, "%d%c", t*4000+next()%2000, t || i<n-1?' ':'\n'), i++);
}
void gen3(int n)
{
	createtest();
	int i;
	for(fprintf(f, "%d 1\n", n), i=0; i<n; fprintf(f, "%d%c", i%2*400000, i<n-1?' ':'\n'), i++);
}
void gen4(int n)
{
	createtest();
	int i;
	fprintf(f, "%d %d\n", n, n/2);
	for(i=0; i<n/2; fprintf(f, "%d ", i*150), i++);
	for(; i<n; fprintf(f, "%d%c", 399500, i<n-1?' ':'\n'), i++);
}
void gen5(int n)
{
	createtest();
	int i;
	fprintf(f, "%d %d\n", n, n/2);
	for(i=0; i<n/2; fprintf(f, "%d ", 400000-i*150), i++);
	for(; i<n; fprintf(f, "%d%c", 123, i<n-1?' ':'\n'), i++);
}
void gen6(int n)
{
	createtest();
	int i;
	fprintf(f, "%d %d\n", n, n/2);
	for(i=0; i<n/2; fprintf(f, "%d ", i*150), i++);
	for(; i<n; fprintf(f, "%d%c", 400000+i-n, i<n-1?' ':'\n'), i++);
}
void gen7(int n)
{
	createtest();
	int i;
	fprintf(f, "%d %d\n", n, n/3);
	for(i=0; i<n/3; fprintf(f, "%d ", 30000+i*200), i++);
	for(; i<2*n/3; fprintf(f, "%d ", 0), i++);
	for(; i<n; fprintf(f, "%d%c", 400000, i<n-1?' ':'\n'), i++);
}
void gen8(int n, int k)
{
	createtest();
	int i;
	for(fprintf(f, "%d %d\n", n, k), i=0; i<n; fprintf(f, "%d%c", i*(400000/n)+next()%5, i<n-1?' ':'\n'), i++);
}
void gen9(int n, int k)
{
	createtest();
	int i;
	for(fprintf(f, "%d %d\n", n, k), i=0; i<n; fprintf(f, "%d%c", 400000-next()%100, i<n-1?' ':'\n'), i++);
}
int GetR( int A, int B, int a, int b, int i )
{
	return A + (double)(i - a) * (B - A) / (b - a);
}
void gen10(int n, int k, int m, int x)
{
	createtest();
	int i;
	fprintf(f, "%d %d\n", n, k);
	for(i=0; i<n; i++)
	{
		int r;
		if(i<x)
			r=i;
		else if(i>n-x)
			r=m-n + i + 1;
		else
			r=GetR(x, m-x, x, n-x, i);
		fprintf(f, "%d%c", r, " \n"[i == n - 1]);
	}
}
int main()
{
	int i;
	gen0();
	for(i=0; i<10; i++)
		gen1(100, 10);
	gen2(50, 40, 100);
	gen2(50, 20, 100);
	gen2(50, 10, 100);
	gen2(50, 5, 100);
	gen2(50, 3, 100);
	gen2(500, 100, 10);
	gen1(5000, 5000);
	gen1(5000, 4000);
	gen1(5000, 1000);
	gen1(5000, 300);
	gen1(5000, 20);
	gen1(5000, 3);
	gen3(5000);
	gen4(5000);
	gen5(5000);
	gen6(5000);
	gen7(4998);
	gen8(5000, 500);
	gen9(5000, 50);
	gen10(5000, 4950, 400000, 25);
	gen10(5000, 4010, 400000, 500);
	return 0;
}